package com.cddx.logistics.controller;

import com.cddx.logistics.domain.dto.AnnualLedgerQueryDTO;
import com.cddx.logistics.domain.dto.LedgerQueryDTO;
import com.cddx.logistics.domain.dto.StockOperationQueryDTO;
import com.cddx.logistics.domain.dto.plan.LedgerQueryDTO;
import com.cddx.logistics.domain.vo.LedgerVO;
import com.cddx.logistics.service.PlanService;
import com.cddx.logistics.service.StockOperationService;
import com.cddx.logistics.util.model.R;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ledger")
@Api(tags = "出入库台账管理")
public class LedgerController {
    @Resource
    private StockOperationService stockOperationService;
    @Autowired
    private PlanService planService;

    @GetMapping("/annual/queryPage")
    public R queryPage(AnnualLedgerQueryDTO queryDTO) {
        PageInfo<?> pageInfo = stockOperationService.queryAnnualLedger(queryDTO);
        return R.ok(pageInfo);
    }
    @PostMapping("/queryPage")
    public R queryPage(@RequestBody LedgerQueryDTO queryDTO) {
        PageInfo<LedgerVO> pageInfo = stockOperationService.queryPageToLedger(queryDTO);
        return R.ok(pageInfo);
    }

    @GetMapping("/getPlan")
    @ApiOperation("获取计划类型列表")
    public R getPlan(){
        return R.ok(planService.queryAll());
    }
}